package com.powernode.api;

import com.powernode.common.ResultJson;
import com.powernode.service.FileService;
import io.minio.errors.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * @Description TODO
 * @Date 2022/3/31 22:58
 * @Version 1.0
 */
@RestController
@RequestMapping("/file")
public class FileApi {

    @Resource
    private FileService fileService;

    @PostMapping("/upload")
    String upload(@RequestPart("file") MultipartFile file, @RequestParam("bucket") String bucket) throws IOException, InvalidKeyException, InvalidResponseException, InsufficientDataException, NoSuchAlgorithmException, ServerException, ErrorResponseException, XmlParserException, InternalException {
        return fileService.upload(file,"image");
    }
}
